public class InterruptInSleepExample {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            try {
                System.out.println("线程开始执行，准备休眠");
                Thread.sleep(5000);  // 模拟长时间的阻塞操作
                System.out.println("线程正常执行完毕");
            } catch (InterruptedException e) {
                System.out.println("线程被中断，异常信息：" + e.getMessage());
            }
        });

        thread.start();

        try {
            // 等待 2 秒钟然后中断线程
            Thread.sleep(2000);
            thread.interrupt();  // 请求中断线程
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
